﻿using System;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using AnyOffice.Components;
using AnyOffice.DAL;
using AnyOffice.Model;
using Microsoft.ApplicationBlocks.Data;

namespace AnyOffice.general.system.menu
{
    public partial class edit : ModulePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.Page.IsPostBack && (Request.QueryString["menu_id"] != null))
            {
                string menuId = Request.QueryString["menu_id"].ToString();
                this.ViewState["MenuId"] = menuId;
                DataTable table = new SysMenuDao().SelectByMenuId(base.Conn, menuId);
                if (table.Rows.Count > 0)
                {
                    this.txtMenuId.Value = table.Rows[0]["MenuId"].ToString();
                    this.txtMenuName.Value = table.Rows[0]["MenuName"].ToString();
                    this.txtImage.Value = table.Rows[0]["Image"].ToString();
                }
            }
            if (this.Page.IsPostBack)
            {
                SysMenuData data = new SysMenuData();
                data.MenuId = this.ViewState["MenuId"].ToString();
                data.MenuName = this.txtMenuName.Value;
                data.Image = this.txtImage.Value;
                new SysMenuDao().Update(base.Conn, data);
                this.pnlMain.Visible = false;
                this.litMessage.Text = base.ShowMessage("修改成功！") + "<script>parent.menu_list.location.reload();</script>";
            }
        } 

    }
}
